import request from '@/utils/request'

export function login (username, password) {
  return request({
    url: '/admin/login',
    method: 'post',
    data: {
      username,
      password
    }
  })
}

export function getInfo () {
  return request({
    url: '/admin/info',
    method: 'get'
  })
}

export function logout () {
  return request({
    url: '/admin/logout',
    method: 'post'
  })
}

export function fetchList (params) {
  return request({
    url: '/admin/list',
    method: 'get',
    params: params
  })
}

export function fetchMemberList (params) {
  return request({
    url: '/member/list',
    method: 'get',
    params: params
  })
}

export function umsDeptList (params) {
  return request({
    url: '/umsDept/list',
    method: 'get',
    params: params
  })
}
// 删除机构
export function umsDeptDel (params) {
  return request({
    url: '/umsDept/delById',
    method: 'get',
    params: params
  })
}

// 查看机构
export function umsDeptGet (params) {
  return request({
    url: '/umsDept/getById',
    method: 'get',
    params: params
  })
}

// 更新/umsDept/update
export function updateUmsDept (id, data) {
  return request({
    url: '/umsDept/update',
    method: 'post',
    data: data
  })
}

// 新增/umsDept/save
export function saveUmsDept (id, data) {
  return request({
    url: '/umsDept/save',
    method: 'post',
    data: data
  })
}
// 业务范围/curCourseType/list
export function curCourseTypeList (params) {
  return request({
    url: '/curCourseType/list',
    method: 'get',
    params
  })
}

// 业务类别字典文件 /common/list dept_type
export function commonListLB () {
  return request({
    url: '/common/list?commonType=dept_type',
    method: 'get'
  })
}

export function createAdmin (data) {
  return request({
    url: '/admin/register',
    method: 'post',
    data: data
  })
}

export function updateAdmin (id, data) {
  return request({
    url: '/admin/update/' + id,
    method: 'post',
    data: data
  })
}

export function updateMemberAdmin (data) {
  return request({
    url: '/member/update',
    method: 'post',
    data: data
  })
}

export function updateStatus (id, params) {
  return request({
    url: '/admin/updateStatus/' + id,
    method: 'post',
    params: params
  })
}

export function deleteAdmin (id) {
  return request({
    url: '/admin/delete/' + id,
    method: 'post'
  })
}

export function getRoleByAdmin (id) {
  return request({
    url: '/admin/role/' + id,
    method: 'get'
  })
}

export function allocRole (data) {
  return request({
    url: '/admin/role/update',
    method: 'post',
    data: data
  })
}

export function findCommunity (params) {
  return request({
    url: '/memberGroup/findCommunity',
    method: 'get',
    params
  })
}

export function findGroups (params) {
  return request({
    url: '/memberGroup/findGroups',
    method: 'get',
    params
  })
}

export function findMembers (params) {
  return request({
    url: '/memberGroup/findMembers',
    method: 'get',
    params
  })
}
